home *** CD-ROM | disk | FTP | other *** search
/ boe.pres.k12.wv.us / boe.pres.k12.wv.us.zip / boe.pres.k12.wv.us / Utilities / Xerox Workcentre 5335 / Windows Utilities / Font Management Utility / Deutsch / Xerox Font Management Utility.msi / Data1.cab / F3722_Fmu.chm / skinsupport / madcapeffects.js < prev    next >
Text File  |  2009-07-16  |  23KB  |  868 lines

  1. // {{MadCap}} //////////////////////////////////////////////////////////////////
  2. // Copyright: MadCap Software, Inc - www.madcapsoftware.com ////////////////////
  3. ////////////////////////////////////////////////////////////////////////////////
  4. // <version>3.0.0.0</version>
  5. ////////////////////////////////////////////////////////////////////////////////
  6.  
  7. var gPopupObj           = null;
  8. var gPopupBGObj         = null;
  9. var gJustPopped         = false;
  10.  
  11. var gFadeID             = 0;
  12.  
  13. var gTextPopupBody      = null;
  14. var gTextPopupBodyBG    = null;
  15.  
  16. var gImgNode            = null;
  17.  
  18. function FMCImageSwap( img, swapType )
  19. {
  20.     var state    = FMCGetMCAttribute( img, "MadCap:state" );
  21.     
  22.     switch ( swapType )
  23.     {
  24.         case "swap":
  25.             var src        = img.src;
  26.             var altsrc2    = FMCGetMCAttribute( img, "MadCap:altsrc2" );
  27.             
  28.             if ( !altsrc2 )
  29.             {
  30.                 altsrc2 = FMCGetMCAttribute( img, "MadCap:altsrc" );
  31.             }
  32.             
  33.             img.src = altsrc2;
  34.             img.setAttribute( "MadCap:altsrc2", src );
  35.             img.setAttribute( "MadCap:state", (state == null || state == "close") ? "open" : "close" );
  36.             
  37.             break;
  38.             
  39.         case "open":
  40.             if ( state != swapType )
  41.             {
  42.                 FMCImageSwap( img, "swap" );
  43.             }
  44.             
  45.             break;
  46.             
  47.         case "close":
  48.             if ( state == "open" )
  49.             {
  50.                 FMCImageSwap( img, "swap" );
  51.             }
  52.             
  53.             break;
  54.     }
  55. }
  56.  
  57. function FMCExpandAll( swapType )
  58. {
  59.     var nodes   = FMCGetElementsByAttribute( document, "MadCap:targetName", "*" );
  60.     
  61.     for ( var i = 0; i < nodes.length; i++ )
  62.     {
  63.         nodes[i].style.display = (swapType == "open") ? "" : "none";
  64.     }
  65.     
  66.     nodes = FMCGetElementsByClassRoot( document, "MCTogglerIcon" );
  67.     
  68.     for ( var i = 0; i < nodes.length; i++ )
  69.     {
  70.         FMCImageSwap( nodes[i], swapType );
  71.     }
  72.     
  73.     nodes = FMCGetElementsByClassRoot( document, "MCExpandingBody" );
  74.     
  75.     for ( var i = 0; i < nodes.length; i++ )
  76.     {
  77.         nodes[i].style.display = (swapType == "open") ? "" : "none";
  78.     }
  79.     
  80.     nodes = FMCGetElementsByClassRoot( document, "MCExpandingIcon" );
  81.     
  82.     for ( var i = 0; i < nodes.length; i++ )
  83.     {
  84.         FMCImageSwap( nodes[i], swapType );
  85.     }
  86.     
  87.     nodes = FMCGetElementsByClassRoot( document, "MCDropDownBody" );
  88.     
  89.     for ( var i = 0; i < nodes.length; i++ )
  90.     {
  91.         nodes[i].style.display = (swapType == "open") ? "" : "none";
  92.     }
  93.     
  94.     nodes = FMCGetElementsByClassRoot( document, "MCDropDownIcon" );
  95.     
  96.     for ( var i = 0; i < nodes.length; i++ )
  97.     {
  98.         FMCImageSwap( nodes[i], swapType );
  99.     }
  100. }
  101.  
  102. function FMCDropDown( node )
  103. {
  104.     // Find head node
  105.     
  106.     var headNode    = node;
  107.     
  108.     while ( !FMCContainsClassRoot( headNode.className, "MCDropDown", "GlossaryPageEntry" ) )
  109.     {
  110.         headNode = headNode.parentNode;
  111.     }
  112.     
  113.     // Toggle the icon
  114.     
  115.     var imgNodes    = node.getElementsByTagName( "img" );
  116.     
  117.     for ( var i = 0; i < imgNodes.length; i++ )
  118.     {
  119.         var imgNode = imgNodes[i];
  120.         
  121.         if ( FMCContainsClassRoot( imgNode.className, "MCDropDownIcon" ) )
  122.         {
  123.             FMCImageSwap( imgNode, "swap" );
  124.             
  125.             break;
  126.         }
  127.     }
  128.     
  129.     // Hide/unhide the body
  130.     
  131.     var id              = node.id.substring( "MCDropDownHotSpot_".length, node.id.length );
  132.     var dropDownBody    = document.getElementById( "MCDropDownBody_" + id );
  133.     
  134.     dropDownBody.style.display = (dropDownBody.style.display == "none") ? "" : "none";
  135. }
  136.  
  137. function FMCExpand( node )
  138. {
  139.     // Find top node
  140.     
  141.     while ( !FMCContainsClassRoot( node.className, "MCExpanding" ) )
  142.     {
  143.         node = node.parentNode;
  144.     }
  145.     
  146.     var nodes       = node.childNodes;
  147.     var imgNodes    = node.getElementsByTagName( "img" );
  148.     
  149.     // Toggle the icon
  150.     
  151.     for ( var i = 0; i < imgNodes.length; i++ )
  152.     {
  153.         var imgNode = imgNodes[i];
  154.         
  155.         if ( FMCContainsClassRoot( imgNode.className, "MCExpandingIcon" ) )
  156.         {
  157.             FMCImageSwap( imgNode, "swap" );
  158.             
  159.             break;
  160.         }
  161.     }
  162.     
  163.     // Hide/unhide the body
  164.     
  165.     var expandingBody;
  166.     
  167.     for ( i = 0; i < nodes.length; i++ )
  168.     {
  169.         var node = nodes[i];
  170.         
  171.         if ( FMCContainsClassRoot( node.className, "MCExpandingBody" ) )
  172.         {
  173.             expandingBody = node;
  174.             break;
  175.         }
  176.     }
  177.     
  178.     expandingBody.style.display = (expandingBody.style.display == "none") ? "" : "none";
  179. }
  180.  
  181. function FMCPopup( e, node )
  182. {
  183.     // Don't continue if something is already popped up
  184.     
  185.     if ( gPopupObj )
  186.     {
  187.         return;
  188.     }
  189.     
  190.     if ( !e )
  191.     {
  192.         e = window.event;
  193.     }
  194.     
  195.     if ( FMCInPreviewMode() && document.documentElement.innerHTML.indexOf( "<!-- saved from url" ) != -1 )
  196.     {
  197.         var span    = document.getElementById( "MCTopicPopupWarning" );
  198.         
  199.         if ( !span )
  200.         {
  201.             span = document.createElement( "span" );
  202.             span.id = "MCTopicPopupWarning";
  203.             span.className = "MCTextPopupBody";
  204.             span.style.display = "none";
  205.             span.appendChild( document.createTextNode( "Topic popups can not be displayed when Insert Mark of the Web is enabled in the target." ) );
  206.             
  207.             document.body.appendChild( span );
  208.         }
  209.         
  210.         gTextPopupBody = span;
  211.         
  212.         FMCShowTextPopup( e );
  213.         
  214.         return;
  215.     }
  216.     
  217.     // Toggle the icon
  218.     
  219.     var imgNodes    = node.getElementsByTagName( "img" );
  220.     
  221.     for ( var i = 0; i < imgNodes.length; i++ )
  222.     {
  223.         var imgNode = imgNodes[i];
  224.         
  225.         if ( FMCContainsClassRoot( imgNode.className, "MCExpandingIcon" ) )
  226.         {
  227.             FMCImageSwap( imgNode, "swap" );
  228.             gImgNode = imgNode;
  229.             
  230.             break;
  231.         }
  232.     }
  233.     
  234.     // Find iframe node
  235.     
  236.     var popupBody;
  237.     
  238.     if ( node.nodeName == "AREA" )
  239.     {
  240.         var iframeName  = FMCGetMCAttribute( node, "MadCap:iframeName" );
  241.         var iframes     = document.getElementsByTagName( "iframe" );
  242.         
  243.         for ( var i = 0; i < iframes.length; i++ )
  244.         {
  245.             var iframe  = iframes[i];
  246.             
  247.             if ( iframe.name == iframeName )
  248.             {
  249.                 popupBody = iframe;
  250.                 break;
  251.             }
  252.         }
  253.     }
  254.     else
  255.     {
  256.         while ( !FMCContainsClassRoot( node.className, "MCPopup" ) )
  257.         {
  258.             node = node.parentNode;
  259.         }
  260.         
  261.         var nodes   = node.childNodes;
  262.         
  263.         for ( i = 0; i < nodes.length; i++ )
  264.         {
  265.             var node    = nodes[i];
  266.             
  267.             if ( FMCContainsClassRoot( node.className, "MCPopupBody" ) )
  268.             {
  269.                 popupBody = node;
  270.                 break;
  271.             }
  272.         }
  273.     }
  274.     
  275.     // Hide/unhide the body
  276.     
  277.     if ( popupBody.style.display == "none" )
  278.     {
  279.         gJustPopped = true;
  280.         
  281.         popupBody.MCClientX = e.clientX;
  282.         popupBody.MCClientY = e.clientY;
  283.  
  284.         var iframe  = frames[popupBody.name];
  285.         var src     = FMCGetMCAttribute( popupBody, "MadCap:src" );
  286.         var path    = null;
  287.         
  288.         if ( src.StartsWith( "http" ) || FMCInPreviewMode() )
  289.         {
  290.             path = src;
  291.         }
  292.         else
  293.         {
  294.             var currentUrl    = document.location.href;
  295.             
  296.             path = currentUrl.substring( 0, currentUrl.lastIndexOf( "/" ) + 1 )
  297.             path = path + src;
  298.         }
  299.  
  300.         // Safari
  301.  
  302.         if ( FMCIsSafari() )
  303.         {
  304.             if ( !popupBody.MCOpened )
  305.             {
  306.                 popupBody.MCOpened = true;
  307.                 
  308.                 popupBody.src = src;
  309.             }
  310.             
  311.             if ( src.substring( 0, 4 ) == "http" )
  312.             {
  313.                 FMCIFrameOnload( popupBody ); // Safari bug: if src of iframe is external, onload event doesn't get triggered so trigger it manually.
  314.             }
  315.             else
  316.             {
  317.                 popupBody.style.display = ""; // Triggers onload event
  318.             }
  319.  
  320.             return;
  321.         }
  322.  
  323.         //
  324.  
  325.         if ( !popupBody.MCOpened )
  326.         {
  327.             popupBody.MCOpened = true;
  328.  
  329.             iframe.document.location.replace( path );
  330.         }
  331.         else
  332.         {
  333.             FMCIFrameOnload( popupBody );
  334.         }
  335.     }
  336. }
  337.  
  338. function FMCIFrameOnload( popupBody )
  339. {
  340.     if ( !popupBody.MCOpened )
  341.     {
  342.         return;
  343.     }
  344.     else if ( popupBody.style.display == "" && !FMCIsSafari() ) // Mozilla: When the popup is clicked, the onload gets called twice, so return the second time.
  345.     {
  346.         return;
  347.     }
  348.  
  349.     popupBody.style.display = "";
  350.     FMCSetPopupSize( popupBody );
  351.     
  352.     var clientX                = popupBody.MCClientX;
  353.     var clientY                = popupBody.MCClientY;
  354.     var absolutePosition    = FMCGetPosition( popupBody.offsetParent );
  355.     var absoluteTop            = absolutePosition[0];
  356.     var absoluteLeft        = absolutePosition[1];
  357.     var newTop                = 0;
  358.     var newLeft                = 0;
  359.     
  360.     // "+ 5" is to account for width of popup shadow.
  361.     
  362.     if ( clientY + parseInt( popupBody.style.height ) + 5 > FMCGetClientHeight( window, false ) )
  363.     {
  364.         newTop = FMCGetScrollTop( window ) + FMCGetClientHeight( window, false ) - parseInt( popupBody.style.height ) - 5;
  365.     }
  366.     else
  367.     {
  368.         newTop = clientY + FMCGetScrollTop( window );
  369.     }
  370.     
  371.     newTop -= absoluteTop;
  372.     popupBody.style.top = newTop + "px";
  373.     
  374.     if ( clientX + parseInt( popupBody.style.width ) + 5 > FMCGetClientWidth( window, false ) )
  375.     {
  376.         newLeft = FMCGetScrollLeft( window ) + FMCGetClientWidth( window, false ) - parseInt( popupBody.style.width ) - 5;
  377.     }
  378.     else
  379.     {
  380.         newLeft = clientX + FMCGetScrollLeft( window );
  381.     }
  382.     
  383.     newLeft -= absoluteLeft;
  384.     popupBody.style.left = newLeft + "px";
  385.     
  386.     // Set up background
  387.     
  388.     var popupBodyBG = document.createElement( "span" );
  389.     
  390.     popupBodyBG.className = "MCPopupBodyBG";
  391.     popupBodyBG.style.top = newTop + 5 + "px";
  392.     popupBodyBG.style.left = newLeft + 5 + "px";
  393.     popupBodyBG.style.width = parseInt( popupBody.offsetWidth ) + "px";
  394.     popupBodyBG.style.height = parseInt( popupBody.offsetHeight ) + "px";
  395.     
  396.     popupBody.parentNode.appendChild( popupBodyBG );
  397.     gPopupObj = popupBody;
  398.     gPopupBGObj = popupBodyBG;
  399.     
  400.     //
  401.     
  402.     gFadeID = setInterval( "FMCFade()", 10 );
  403. }
  404.  
  405. function FMCSetPopupSize( popupNode )
  406. {
  407.     var popupWidth    = popupNode.style.width;
  408.     var popupHeight    = popupNode.style.height;
  409.     
  410.     if ( (popupWidth != "auto" && !popupWidth.IsNullOrEmpty()) || (popupHeight != "auto" && !popupHeight.IsNullOrEmpty()) )
  411.     {
  412.         return;
  413.     }
  414.     
  415.     //
  416.     
  417.     var clientWidth     = FMCGetClientWidth( window, false );
  418.     var clientHeight    = FMCGetClientHeight( window, false );
  419.     var stepSize        = 10;
  420.     var hwRatio         = clientHeight / clientWidth;
  421.     var popupFrame      = frames[popupNode.name];
  422.     var maxX            = clientWidth * 0.618034;
  423.     var i               = 0;
  424.     
  425.     // Debug
  426.     //window.status += document.body.clientHeight + ", " + document.body.offsetHeight + ", " + document.body.scrollHeight + ", " + document.body.scrollTop;
  427.     //window.status += " : " + document.documentElement.clientHeight + ", " + document.documentElement.offsetHeight + ", " + document.documentElement.scrollHeight + ", " + document.documentElement.scrollTop;
  428.     
  429.     // Safari
  430.     
  431.     if ( FMCIsSafari() )
  432.     {
  433.         popupNode.style.width = maxX + "px";
  434.         popupNode.style.height = (maxX * hwRatio) + "px";
  435.         
  436.         return;
  437.     }
  438.     
  439.     //
  440.     
  441.     try
  442.     {
  443.         var popupDocument   = popupFrame.document; // This will throw an exception in IE.
  444.         
  445.         FMCGetScrollHeight( popupFrame.window );   // This will throw an exception in Mozilla.
  446.     }
  447.     catch ( err )
  448.     {
  449.         popupNode.style.width = maxX + "px";
  450.         popupNode.style.height = (maxX * hwRatio) + "px";
  451.         
  452.         return;
  453.     }
  454.     
  455.     while ( true )
  456.     {
  457.         popupNode.style.width = maxX - (i * stepSize) + "px";
  458.         popupNode.style.height = (maxX - (i * stepSize)) * hwRatio + "px";
  459.         
  460.         if ( FMCGetScrollHeight( popupFrame.window ) > FMCGetClientHeight( popupFrame.window, false ) ||
  461.              FMCGetScrollWidth( popupFrame.window ) > FMCGetClientWidth( popupFrame.window, false ) )
  462.         {
  463.             popupNode.style.width = maxX - ((i - 1) * stepSize) + "px";
  464.             popupNode.style.height = (maxX - ((i - 1) * stepSize)) * hwRatio + "px";
  465.             
  466.             break;
  467.         }
  468.         
  469.         i++;
  470.     }
  471. }
  472.  
  473. function GetHelpControlLinks( node, callbackFunc, callbackArgs )
  474. {
  475.     var linkMap            = new Array();
  476.     var inPreviewMode    = FMCInPreviewMode();
  477.     var rootFrame        = FMCGetRootFrame();
  478.  
  479.     if ( !inPreviewMode && rootFrame.gHelpSystem.IsMerged() && FMCGetMCAttribute( node, "MadCap:indexKeywords" ) != null )
  480.     {
  481.         function OnInit()
  482.         {
  483.             var indexKeywords   = FMCGetMCAttribute( node, "MadCap:indexKeywords" ).replace( "\\;", "%%%%%" );
  484.             
  485.             if ( indexKeywords == "" )
  486.             {
  487.                 callbackFunc( linkMap, callbackArgs );
  488.             }
  489.             
  490.             var keywords        = indexKeywords.split( ";" );
  491.             
  492.             for ( var i = 0; i < keywords.length; i++ )
  493.             {
  494.                 keywords[i] = keywords[i].replace( "%%%%%", ";" );
  495.                 
  496.                 var currKeyword = keywords[i].replace( "\\:", "%%%%%" );
  497.                 var keywordPath = currKeyword.split( ":" );
  498.                 var level       = keywordPath.length - 1;
  499.                 var indexKey    = level + "_" + keywordPath[level].replace( "%%%%%", ":" );
  500.                 
  501.                 var currLinkMap = indexFrame.gLinkMap.GetItem( indexKey.toLowerCase() );
  502.                 
  503.                 // currLinkMap may be blank if keywords[i] isn't found in index XML file (user may have deleted keyword after associating it with a K-Link)
  504.                 
  505.                 if ( currLinkMap )
  506.                 {
  507.                     for ( var key in currLinkMap.GetKeys() )
  508.                     {
  509.                         linkMap[linkMap.length] = key + "|" + currLinkMap.GetItem( key );
  510.                     }
  511.                 }
  512.             }
  513.  
  514.             callbackFunc( linkMap, callbackArgs );
  515.         }
  516.  
  517.         var indexFrame  = rootFrame.frames["navigation"].frames["index"];
  518.         
  519.         indexFrame.Init( OnInit );
  520.  
  521.         return;
  522.     }
  523.     else if ( !inPreviewMode && rootFrame.gHelpSystem.IsMerged() && FMCGetMCAttribute( node, "MadCap:concepts" ) != null )
  524.     {
  525.         var concepts    = FMCGetMCAttribute( node, "MadCap:concepts" );
  526.         var args        = { callbackFunc: callbackFunc, callbackArgs: callbackArgs };
  527.         
  528.         rootFrame.gHelpSystem.GetConceptsLinks( concepts, OnGetConceptsLinks, args );
  529.         
  530.         return;
  531.     }
  532.     else if ( FMCGetMCAttribute( node, "MadCap:topics" ) != null )
  533.     {
  534.         var topics  = FMCGetMCAttribute( node, "MadCap:topics" ).split( "||" );
  535.         
  536.         if ( topics == "" )
  537.         {
  538.             callbackFunc( linkMap, callbackArgs );
  539.         }
  540.         
  541.         for ( var i = 0; i < topics.length; i++ )
  542.         {
  543.             linkMap[linkMap.length] = topics[i];
  544.         }
  545.     }
  546.  
  547.     callbackFunc( linkMap, callbackArgs );
  548. }
  549.  
  550. function OnGetConceptsLinks( links, args )
  551. {
  552.     var callbackFunc    = args.callbackFunc;
  553.     var callbackArgs    = args.callbackArgs;
  554.     
  555.     callbackFunc( links, callbackArgs );
  556. }
  557.  
  558. function FMCTextPopup( e, node )
  559. {
  560.     // Don't continue if something is already popped up
  561.     
  562.     if ( gPopupObj )
  563.     {
  564.         return;
  565.     }
  566.     
  567.     if ( !e )
  568.     {
  569.         e = window.event;
  570.     }
  571.     
  572.     // Find top node
  573.     
  574.     while ( !FMCContainsClassRoot( node.className, "MCTextPopup" ) )
  575.     {
  576.         node = node.parentNode;
  577.     }
  578.     
  579.     // Toggle the icon
  580.     
  581.     var imgNodes    = node.getElementsByTagName( "img" );
  582.     
  583.     for ( var i = 0; i < imgNodes.length; i++ )
  584.     {
  585.         var imgNode = imgNodes[i];
  586.         
  587.         if ( FMCContainsClassRoot( imgNode.className, "MCExpandingIcon" ) )
  588.         {
  589.             FMCImageSwap( imgNode, "swap" );
  590.             gImgNode = imgNode;
  591.             
  592.             break;
  593.         }
  594.     }
  595.     
  596.     // Hide/unhide the body
  597.     
  598.     var nodes   = node.childNodes;
  599.     
  600.     for ( i = 0; i < nodes.length; i++ )
  601.     {
  602.         var node = nodes[i];
  603.         
  604.         if ( FMCContainsClassRoot( node.className, "MCTextPopupBody" ) )
  605.         {
  606.             gTextPopupBody = node;
  607.             break;
  608.         }
  609.     }
  610.     
  611.     FMCShowTextPopup( e );
  612. }
  613.  
  614. function FMCShowTextPopup( e )
  615. {
  616.     if ( gTextPopupBody.style.display == "none" )
  617.     {
  618.         if ( gTextPopupBody.childNodes.length == 0 )
  619.         {
  620.             gTextPopupBody.appendChild( document.createTextNode( "(No data to display)") );
  621.         }
  622.         
  623.         gTextPopupBody.style.display = "";
  624.         
  625.         FMCSetTextPopupSize( gTextPopupBody );
  626.         
  627.         // "+ 5" is to account for width of popup shadow.
  628.         
  629.         if ( FMCGetClientY( window, e ) + gTextPopupBody.offsetHeight + 5 > FMCGetClientHeight( window, false ) )
  630.         {
  631.             gTextPopupBody.style.top = FMCGetScrollTop( window ) + FMCGetClientHeight( window, false ) - gTextPopupBody.offsetHeight - 5 + "px";
  632.         }
  633.         else
  634.         {
  635.             gTextPopupBody.style.top = FMCGetPageY( window, e ) + "px";
  636.         }
  637.         
  638.         if ( FMCGetClientX( window, e ) + gTextPopupBody.offsetWidth + 5 > FMCGetClientWidth( window, false ) )
  639.         {
  640.             gTextPopupBody.style.left = FMCGetScrollLeft( window ) + FMCGetClientWidth( window, false ) - gTextPopupBody.offsetWidth - 5 + "px";
  641.         }
  642.         else
  643.         {
  644.             gTextPopupBody.style.left = FMCGetPageX( window, e ) + "px";
  645.         }
  646.         
  647.         // Set up background
  648.         
  649.         gTextPopupBodyBG = document.createElement( "span" );
  650.         gTextPopupBodyBG.className = "MCTextPopupBodyBG";
  651.         gTextPopupBodyBG.style.top = parseInt( gTextPopupBody.style.top ) + 5 + "px";
  652.         gTextPopupBodyBG.style.left = parseInt( gTextPopupBody.style.left ) + 5 + "px";
  653.         
  654.         FMCSetTextPopupDimensions();
  655.         
  656.         gTextPopupBody.parentNode.appendChild( gTextPopupBodyBG );
  657.         window.onresize = FMCSetTextPopupDimensions;
  658.         gPopupObj = gTextPopupBody;
  659.         gPopupBGObj = gTextPopupBodyBG;
  660.         gJustPopped = true;
  661.         
  662.         //
  663.         
  664.         gFadeID = setInterval( "FMCFade()", 10 );
  665.     }
  666. }
  667.  
  668. function FMCSetTextPopupSize( popupNode )
  669. {
  670.     var clientWidth     = FMCGetClientWidth( window, false );
  671.     var clientHeight    = FMCGetClientHeight( window, false );
  672.     var stepSize        = 10;
  673.     var hwRatio         = clientHeight / clientWidth;
  674.     var maxX            = clientWidth * 0.618034;
  675.     var i               = 0;
  676.     
  677.     while ( true )
  678.     {
  679.         popupNode.style.width = maxX - (i * stepSize) + "px";
  680.         popupNode.style.height = (maxX - (i * stepSize)) * hwRatio + "px";
  681.         
  682.         // "- 2" is to account for borderLeft + borderRight.
  683.         
  684.         if ( popupNode.scrollHeight > popupNode.offsetHeight - 2 || popupNode.scrollWidth > popupNode.offsetWidth - 2 )
  685.         {
  686.             popupNode.style.overflow = "hidden";    // Since scrollbars are now present, temporarily remove them before enlarging the node or else they'll still be present
  687.             popupNode.style.overflow = "auto";      // Allow scrollbars again.
  688.             
  689.             popupNode.style.width = maxX - ((i - 1) * stepSize) + "px";
  690.             popupNode.style.height = (maxX - ((i - 1) * stepSize)) * hwRatio + "px";
  691.             
  692.             break;
  693.         }
  694.         
  695.         i++;
  696.     }
  697.     
  698.     // Debug
  699.     //window.status = popupNode.offsetWidth + ", " + popupNode.scrollWidth + ", " + popupNode.offsetHeight + ", " + popupNode.scrollHeight;
  700. }
  701.  
  702. function FMCToggler( node )
  703. {
  704.     // Don't continue if something is already popped up
  705.     
  706.     if ( gPopupObj )
  707.     {
  708.         return;
  709.     }
  710.     
  711.     // Toggle the icon
  712.     
  713.     var imgNodes    = node.getElementsByTagName( "img" );
  714.     
  715.     for ( var i = 0; i < imgNodes.length; i++ )
  716.     {
  717.         var imgNode = imgNodes[i];
  718.         
  719.         if ( FMCContainsClassRoot( imgNode.className, "MCTogglerIcon" ) )
  720.         {
  721.             FMCImageSwap( imgNode, "swap" );
  722.             
  723.             break;
  724.         }
  725.     }
  726.     
  727.     // Toggle all toggler items
  728.     
  729.     var targets = FMCGetMCAttribute( node, "MadCap:targets" ).split( ";" );
  730.     
  731.     for ( var i = 0; i < targets.length; i++ )
  732.     {
  733.         var nodes   = FMCGetElementsByAttribute( document, "MadCap:targetName", targets[i] );
  734.         
  735.         for ( var j = 0; j < nodes.length; j++ )
  736.         {
  737.             if ( nodes[j].style.display == "none" )
  738.             {
  739.                 nodes[j].style.display = "";
  740.                 
  741.                 FMCUnhide( window, nodes[j] );
  742.             }
  743.             else
  744.             {
  745.                 nodes[j].style.display = "none";
  746.             }
  747.         }
  748.     }
  749. }
  750.  
  751. function FMCSetTextPopupDimensions()
  752. {
  753.     gTextPopupBodyBG.style.width = gTextPopupBody.offsetWidth + "px";
  754.     gTextPopupBodyBG.style.height = gTextPopupBody.offsetHeight + "px";
  755. }
  756.  
  757. function FMCFade()
  758. {
  759.     var finished    = false;
  760.     
  761.     if ( gPopupObj.filters )
  762.     {
  763.         var opacity    = gPopupObj.style.filter;
  764.         
  765.         if ( opacity == "" )
  766.         {
  767.             opacity = "alpha( opacity = 0 )";
  768.         }
  769.         
  770.         gPopupObj.style.filter = "alpha( opacity = " + (parseInt( opacity.substring( 17, opacity.length - 2 ) ) + 10) + " )";
  771.         
  772.         if ( gPopupBGObj )
  773.         {
  774.             opacity = gPopupBGObj.style.filter;
  775.             
  776.             if ( opacity == "" )
  777.             {
  778.                 opacity = "alpha( opacity = 0 )";
  779.             }
  780.             
  781.             gPopupBGObj.style.filter = "alpha( opacity = " + (parseInt( opacity.substring( 17, opacity.length - 2 ) ) + 5) + " )";
  782.         }
  783.         
  784.         if ( gPopupObj.style.filter == "alpha( opacity = 100 )" )
  785.         {
  786.             finished = true;
  787.         }
  788.     }
  789.     else if ( gPopupObj.style.MozOpacity != null )
  790.     {
  791.         var opacity    = gPopupObj.style.MozOpacity;
  792.         
  793.         if ( opacity == "" )
  794.         {
  795.             opacity = "0.0";
  796.         }
  797.         
  798.         gPopupObj.style.MozOpacity = parseFloat( opacity ) + 0.11;
  799.         
  800.         if ( gPopupBGObj )
  801.         {
  802.             opacity = gPopupBGObj.style.MozOpacity;
  803.             
  804.             if ( opacity == "" )
  805.             {
  806.                 opacity = "0.0";
  807.             }
  808.             
  809.             gPopupBGObj.style.MozOpacity = parseFloat( opacity ) + 0.05;
  810.         }
  811.         
  812.         if ( parseFloat( gPopupObj.style.MozOpacity ) == 0.99 )
  813.         {
  814.             finished = true;
  815.         }
  816.     }
  817.     
  818.     if ( finished )
  819.     {
  820.         clearInterval( gFadeID );
  821.         gFadeID = 0;
  822.     }
  823. }
  824.  
  825. var MCFader    = new function()
  826. {
  827.     // Public methods
  828.  
  829.     this.FadeIn    = function( node, nodeBG )
  830.     {
  831.         var interval    = 0;
  832.         var funcIndex    = -1;
  833.  
  834.         FMCSetOpacity( node, 0 );
  835.         FMCSetOpacity( nodeBG, 0 );
  836.  
  837.         function DoFadeIn()
  838.         {
  839.             var opacity    = FMCGetOpacity( node );
  840.             
  841.             if ( opacity == 0 )
  842.             {
  843.                 function OnClickDocument()
  844.                 {
  845.                     node.parentNode.removeChild( node );
  846.                     nodeBG.parentNode.removeChild( nodeBG );
  847.                     
  848.                     gDocumentOnclickFuncs.splice( funcIndex, 1 );
  849.                 }
  850.                 
  851.                 funcIndex = gDocumentOnclickFuncs.push( OnClickDocument ) - 1;
  852.             }
  853.             
  854.             opacity += 10;
  855.  
  856.             FMCSetOpacity( node, opacity );
  857.             FMCSetOpacity( nodeBG, opacity / 2 );
  858.  
  859.             if ( opacity >= 100 )
  860.             {
  861.                 clearInterval( interval );
  862.             }
  863.         }
  864.  
  865.         interval = setInterval( DoFadeIn, 10 );
  866.     };
  867. }
  868.